home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 April / macformat-023.iso / Shareware in MacFormat / brailler0.5b / brlr ƒ / Shell ƒ / graphics dispatch.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-12-20  |  9.1 KB  |  493 lines  |  [TEXT/MMCC]

  1. #include "graphics dispatch.h"
  2. #include "window layer.h"
  3. #include "program globals.h"
  4. #include "edit functions.h"
  5. #include "about.h"
  6. #include "about MSG.h"
  7. #include "other MSG window.h"
  8. #include "help.h"
  9. #include "brlr main window.h"
  10. #include "brlr floating window.h"
  11.  
  12. extern    Boolean            gPostingEvents;
  13.  
  14. enum DispatchError SetupWindowDispatch(short index, WindowPtr theWindow)
  15. {
  16.     SetWindowIndex(theWindow, index);
  17.     SetWindowTE(theWindow, 0L);
  18.     SetWindowVScrollBar(theWindow, 0L);
  19.     SetWindowHScrollBar(theWindow, 0L);
  20.     
  21.     switch (index)
  22.     {
  23.         case kAboutWindow:
  24.             SetupTheAboutWindow(theWindow);
  25.             return kSuccess;
  26.         case kAboutMSGWindow:
  27.             SetupTheAboutMSGWindow(theWindow);
  28.             return kSuccess;
  29.         case kOtherMSGWindow:
  30.             SetupTheOtherMSGWindow(theWindow);
  31.             return kSuccess;
  32.         case kHelpWindow:
  33.             SetupTheHelpWindow(theWindow);
  34.             return kSuccess;
  35.         case kMainWindow:
  36.             SetupTheMainWindow(theWindow);
  37.             return kSuccess;
  38.         case kFloatingWindow:
  39.             SetupTheFloatingWindow(theWindow);
  40.             return kSuccess;
  41.     }
  42.     
  43.     return kFailure;
  44. }
  45.  
  46. enum DispatchError ShutdownWindowDispatch(short index)
  47. {
  48.     switch (index)
  49.     {
  50.         case kAboutWindow:
  51.             ShutDownTheAboutWindow();
  52.             return kSuccess;
  53.         case kAboutMSGWindow:
  54.             ShutDownTheAboutMSGWindow();
  55.             return kSuccess;
  56.         case kHelpWindow:
  57.             ShutDownTheHelpWindow();
  58.             return kSuccess;
  59.         case kMainWindow:
  60.             ShutDownTheMainWindow();
  61.             return kSuccess;
  62.         case kFloatingWindow:
  63.             ShutDownTheFloatingWindow();
  64.             return kSuccess;
  65.     }
  66.     
  67.     return kFailure;
  68. }
  69.  
  70. enum DispatchError OpenWindowDispatch(short index)
  71. {
  72.     WindowPtr        theWindow;
  73.     
  74.     theWindow=GetIndWindowPtr(index);
  75.     
  76.     switch (index)
  77.     {
  78.         case kAboutWindow:
  79.             OpenTheAboutWindow(theWindow);
  80.             return kSuccess;
  81.         case kAboutMSGWindow:
  82.             OpenTheMSGWindow(theWindow);
  83.             return kSuccess;
  84.         case kOtherMSGWindow:
  85.             OpenTheOtherMSGWindow(theWindow);
  86.             return kSuccess;
  87.         case kHelpWindow:
  88.             OpenTheHelpWindow(theWindow);
  89.             return kSuccess;
  90.         case kMainWindow:
  91.             OpenTheMainWindow(theWindow);
  92.             return kSuccess;
  93.         case kFloatingWindow:
  94.             OpenTheFloatingWindow(theWindow);
  95.             return kSuccess;
  96.     }
  97.     
  98.     return kFailure;
  99. }
  100.  
  101. enum DispatchError CloseWindowDispatch(short index)
  102. {
  103.     WindowPtr        theWindow;
  104.     
  105.     theWindow=GetIndWindowPtr(index);
  106.     
  107.     switch (index)
  108.     {
  109.         case kMainWindow:
  110.             if (CloseTheMainWindow(theWindow))
  111.                 return kSuccess;
  112.             else
  113.                 return kCancel;
  114.         case kFloatingWindow:
  115.             CloseTheFloatingWindow(theWindow);
  116.             return kSuccess;
  117.     }
  118.     
  119.     return kFailure;
  120. }
  121.  
  122. enum DispatchError DisposeWindowDispatch(short index)
  123. {
  124.     WindowPtr        theWindow;
  125.     
  126.     theWindow=GetIndWindowPtr(index);
  127.     
  128.     switch (index)
  129.     {
  130.         case kAboutWindow:
  131.             DisposeTheAboutWindow(theWindow);
  132.             return kSuccess;
  133.         case kOtherMSGWindow:
  134.             DisposeTheOtherMSGWindow(theWindow);
  135.             return kSuccess;
  136.         case kHelpWindow:
  137.             DisposeTheHelpWindow(theWindow);
  138.             return kSuccess;
  139.         case kMainWindow:
  140.             DisposeTheMainWindow(theWindow);
  141.             return kSuccess;
  142.         case kFloatingWindow:
  143.             DisposeTheFloatingWindow(theWindow);
  144.             return kSuccess;
  145.     }
  146.     
  147.     return kFailure;
  148. }
  149.  
  150. enum DispatchError DrawWindowDispatch(short index, short theDepth)
  151. {
  152.     WindowPtr        theWindow;
  153.     
  154.     theWindow=GetIndWindowPtr(index);
  155.     
  156.     switch (index)
  157.     {
  158.         case kAboutMSGWindow:
  159.             DrawTheAboutMSGWindow(theWindow, theDepth);
  160.             return kSuccess;
  161.         case kHelpWindow:
  162.             DrawTheHelpWindow(theWindow, theDepth);
  163.             return kSuccess;
  164.         case kFloatingWindow:
  165.             DrawTheFloatingWindow(theWindow, theDepth);
  166.             return kSuccess;
  167.     }
  168.     
  169.     return kFailure;
  170. }
  171.  
  172. enum DispatchError ChangeDepthDispatch(short index, short newDepth)
  173. {
  174.     WindowPtr        theWindow;
  175.     
  176.     theWindow=GetIndWindowPtr(index);
  177.     
  178.     switch (index)
  179.     {
  180.         case kAboutMSGWindow:
  181.             ChangeDepthTheAboutMSGWindow(theWindow, newDepth);
  182.             return kSuccess;
  183.     }
  184.     
  185.     return kFailure;
  186. }
  187.  
  188. enum DispatchError CopybitsDispatch(short index, WindowPtr offscreenWindow)
  189. {
  190.     WindowPtr        theWindow;
  191.     
  192.     theWindow=GetIndWindowPtr(index);
  193.     
  194.     switch (index)
  195.     {
  196.         case kOtherMSGWindow:
  197.             CopybitsTheOtherMSGWindow(theWindow, offscreenWindow);
  198.             return kSuccess;
  199.         case kMainWindow:
  200.             CopybitsTheMainWindow(theWindow, offscreenWindow);
  201.             return kSuccess;
  202.     }
  203.     
  204.     return kFailure;
  205. }
  206.  
  207. enum DispatchError IdleWindowDispatch(short index, Point mouseLoc)
  208. {
  209.     WindowPtr        theWindow;
  210.     
  211.     theWindow=GetIndWindowPtr(index);
  212.     
  213.     switch (index)
  214.     {
  215.         case kMainWindow:
  216.             IdleInMainWindow(theWindow, mouseLoc);
  217.             return kSuccess;
  218.         case kFloatingWindow:
  219.             IdleInFloatingWindow(theWindow, mouseLoc);
  220.             return kPassThrough;
  221.     }
  222.     
  223.     return kFailure;
  224. }
  225.  
  226. enum DispatchError ActivateWindowDispatch(short index)
  227. {
  228.     WindowPtr        theWindow;
  229.     
  230.     theWindow=GetIndWindowPtr(index);
  231.     
  232.     switch (index)
  233.     {
  234.         case kOtherMSGWindow:
  235.             ActivateTheOtherMSGWindow(theWindow);
  236.             return kSuccess;
  237.         case kMainWindow:
  238.             ActivateTheMainWindow(theWindow);
  239.             return kSuccess;
  240.         case kFloatingWindow:
  241.             ActivateTheFloatingWindow(theWindow);
  242.             return kSuccess;
  243.     }
  244.     
  245.     return kFailure;
  246. }
  247.  
  248. enum DispatchError DeactivateWindowDispatch(short index)
  249. {
  250.     WindowPtr        theWindow;
  251.     
  252.     theWindow=GetIndWindowPtr(index);
  253.     
  254.     switch (index)
  255.     {
  256.         case kOtherMSGWindow:
  257.             DeactivateTheOtherMSGWindow(theWindow);
  258.             return kSuccess;
  259.         case kMainWindow:
  260.             DeactivateTheMainWindow(theWindow);
  261.             return kSuccess;
  262.         case kFloatingWindow:
  263.             DeactivateTheFloatingWindow(theWindow);
  264.             return kSuccess;
  265.     }
  266.     
  267.     return kFailure;
  268. }
  269.  
  270. enum DispatchError GrowWindowDispatch(short index)
  271. {
  272.     WindowPtr        theWindow;
  273.     
  274.     theWindow=GetIndWindowPtr(index);
  275.     
  276.     switch (index)
  277.     {
  278.         case kOtherMSGWindow:
  279.             ResizeControlsInOtherMSGWindow(theWindow);
  280.             return kSuccess;
  281.         case kMainWindow:
  282.             ResizeControlsInMainWindow(theWindow);
  283.             return kSuccess;
  284.     }
  285.     
  286.     return kFailure;
  287. }
  288.  
  289. enum DispatchError ZoomWindowDispatch(short index)
  290. {
  291.     WindowPtr        theWindow;
  292.     
  293.     theWindow=GetIndWindowPtr(index);
  294.     
  295.     switch (index)
  296.     {
  297.         case kOtherMSGWindow:
  298.             ResizeControlsInOtherMSGWindow(theWindow);
  299.             return kSuccess;
  300.         case kMainWindow:
  301.             ResizeControlsInMainWindow(theWindow);
  302.             return kSuccess;
  303.     }
  304.     
  305.     return kFailure;
  306. }
  307.  
  308. enum DispatchError GetGrowSizeDispatch(short index, Rect *sizeRect)
  309. {
  310.     WindowPtr        theWindow;
  311.     
  312.     theWindow=GetIndWindowPtr(index);
  313.     
  314.     switch (index)
  315.     {
  316.         case kOtherMSGWindow:
  317.             GetGrowSizeOtherMSGWindow(theWindow, sizeRect);
  318.             return kSuccess;
  319.         case kMainWindow:
  320.             GetGrowSizeMainWindow(theWindow, sizeRect);
  321.             return kSuccess;
  322.     }
  323.     
  324.     return kFailure;
  325. }
  326.  
  327. enum DispatchError KeyDownDispatch(short index, unsigned char theChar)
  328. {
  329.     WindowPtr        theWindow;
  330.     
  331.     theWindow=GetIndWindowPtr(index);
  332.     
  333.     switch (index)
  334.     {
  335.         case kAboutWindow:
  336.             KeyDownInAboutWindow(theWindow, theChar);
  337.             return kSuccess;
  338.         case kOtherMSGWindow:
  339.             KeyPressedInOtherMSGWindow(theWindow, theChar);
  340.             return kSuccess;
  341.         case kHelpWindow:
  342.             KeyPressedInHelpWindow(theWindow, theChar);
  343.             return kSuccess;
  344.         case kMainWindow:
  345.             KeyPressedInMainWindow(theWindow, theChar);
  346.             return kSuccess;
  347.         case kFloatingWindow:
  348.             if ((gPostingEvents) || (GetFrontDocumentWindow()!=GetIndWindowPtr(kMainWindow)))
  349.                 return kPassThrough;
  350.             else
  351.                 KeyPressedInFloatingWindow(theWindow, theChar);
  352.             return kSuccess;
  353.     }
  354.     
  355.     return kFailure;
  356. }
  357.  
  358. enum DispatchError MouseDownDispatch(short index, Point thePoint)
  359. {
  360.     WindowPtr        theWindow;
  361.     
  362.     theWindow=GetIndWindowPtr(index);
  363.     
  364.     switch (index)
  365.     {
  366.         case kAboutWindow:
  367.             MouseDownInAboutWindow(theWindow, thePoint);
  368.             return kSuccess;
  369.         case kOtherMSGWindow:
  370.             MouseClickedInOtherMSGWindow(theWindow, thePoint);
  371.             return kSuccess;
  372.         case kHelpWindow:
  373.             MouseClickedInHelpWindow(theWindow, thePoint);
  374.             return kSuccess;
  375.         case kMainWindow:
  376.             MouseClickedInMainWindow(theWindow, thePoint);
  377.             return kSuccess;
  378.         case kFloatingWindow:
  379.             MouseClickedInFloatingWindow(theWindow, thePoint);
  380.             return kSuccess;
  381.     }
  382.     
  383.     return kFailure;
  384. }
  385.  
  386. enum DispatchError UndoDispatch(short index)
  387. {
  388.     switch (index)
  389.     {
  390.         case kFloatingWindow:
  391.             return kPassThrough;
  392.             break;
  393.     }
  394.     
  395.     return kFailure;
  396. }
  397.  
  398. enum DispatchError CutDispatch(short index)
  399. {
  400.     WindowPtr        theWindow;
  401.     
  402.     theWindow=GetIndWindowPtr(index);
  403.     
  404.     switch (index)
  405.     {
  406.         case kMainWindow:
  407.             GenericCut(theWindow);
  408.             return kSuccess;
  409.             break;
  410.         case kFloatingWindow:
  411.             return kPassThrough;
  412.             break;
  413.     }
  414.     
  415.     return kFailure;
  416. }
  417.  
  418. enum DispatchError CopyDispatch(short index)
  419. {
  420.     WindowPtr        theWindow;
  421.     
  422.     theWindow=GetIndWindowPtr(index);
  423.     
  424.     switch (index)
  425.     {
  426.         case kMainWindow:
  427.             GenericCopy(theWindow);
  428.             return kSuccess;
  429.         case kFloatingWindow:
  430.             return kPassThrough;
  431.             break;
  432.     }
  433.     
  434.     return kFailure;
  435. }
  436.  
  437. enum DispatchError PasteDispatch(short index)
  438. {
  439.     WindowPtr        theWindow;
  440.     
  441.     theWindow=GetIndWindowPtr(index);
  442.     
  443.     switch (index)
  444.     {
  445.         case kMainWindow:
  446.             GenericPaste(theWindow);
  447.             return kSuccess;
  448.         case kFloatingWindow:
  449.             return kPassThrough;
  450.             break;
  451.     }
  452.     
  453.     return kFailure;
  454. }
  455.  
  456. enum DispatchError ClearDispatch(short index)
  457. {
  458.     WindowPtr        theWindow;
  459.     
  460.     theWindow=GetIndWindowPtr(index);
  461.     
  462.     switch (index)
  463.     {
  464.         case kMainWindow:
  465.             GenericClear(theWindow);
  466.             return kSuccess;
  467.         case kFloatingWindow:
  468.             return kPassThrough;
  469.             break;
  470.     }
  471.     
  472.     return kFailure;
  473. }
  474.  
  475. enum DispatchError SelectAllDispatch(short index)
  476. {
  477.     WindowPtr        theWindow;
  478.     
  479.     theWindow=GetIndWindowPtr(index);
  480.     
  481.     switch (index)
  482.     {
  483.         case kMainWindow:
  484.             GenericSelectAll(theWindow);
  485.             return kSuccess;
  486.         case kFloatingWindow:
  487.             return kPassThrough;
  488.             break;
  489.     }
  490.     
  491.     return kFailure;
  492. }
  493.